classdef spyfilt_nlbl < spyview_filter
    properties (Constant=true)
        name='Norm LBL';
        description='Normalize the contrast in each line';
        parameters=struct('name',{'Sigma','vertical'},'type',{'bool','bool'},'default',{1,0});
    end
    methods
        function [pm,px,py]=filter(sf,pm,px,py)
            if sf.values{1}
                func=@(x,y) nanstd(x,0,y);
            else
                func=@range;
            end
            if ~sf.values{2}
                den=func(pm,2);
                den(isnan(den))=1;
                den(den < max(den)*1e-6)=1;
                pm=pm./repmat(den,1,size(pm,2));
            else
                den=func(pm,1);
                den(isnan(den))=1;
                den(den < max(den)*1e-6)=1;
                pm=pm./repmat(den,size(pm,1),1);
            end
        end
    end
end